<template>
  <span v-if="isShow">
    <slot></slot>
  </span>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "OperationPermission",
  props: {
    check: {
      type: String,
      default: "",
      required: true
    }
  },
  data() {
    return {};
  },
  created() {},
  computed: {
    ...mapState({
      isShow: function(state) {
        const operationList = state.SysPermission.operationPermissionList;
        // debugger;
        let showFlag = true;
        if (operationList.length > 0) {
          showFlag = false;
          operationList.forEach(item => {
            // console.log("aaaaa:" + item.name, this.check);
            if (item.name === this.check) {
              // console.log("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:" + item.allow);
              if (item.allow) {
                showFlag = true;
              }
            }
          });
        }
        console.log("权限id: " + this.check + ": " + showFlag);
        // const show =
        //   operationList.filter(v => v.name === check).length > 0 ? operationList.filter(v => v.name === check)[0].allow : false
        return showFlag;
      }
    })
  },
  mounted() {},
  watch: {},
  methods: {}
};
</script>
